import Vue 			from 'vue'
import util 		from '../../util'
import axios 		from 'axios'
import { Toast,Dialog,List } 	from 'vant';
Vue.use(Toast,Dialog,List);
import {BigNumber}  from 'bignumber.js'

export default {
	name: 'redExchange',
	data(){
		return {
			totalBtc:0,				//持有的BTC数量
			list:[],				//可兑换券列表
			dialogEx:{}
		}
	},
	methods:{
		init(){
			// Toast.loading({
			// 	message: '加载中...',
			// 	duration:0,
			// 	forbidClick: true
			// });
		},
		goBack(){
			util.navigateBack(-1,this)
		}
	},
	created() {
		document.querySelector('body').setAttribute('style', 'background:#120F78');
		util.waitSDKReady().then(token => {
			this.token = token;
			this.init();
		}).catch((e) => {
			Toast('获取token失败')
		})
		setTimeout(() => {
			util.registerHandler('refreshCommonRequestWhenGoBackView',res => {
				if(this.token) this.init();
				util.callHandler('setStatusBarStyle',{
					style:'dark'
				})
			})
			//退出登录的时候native调用H5方法清除token缓存
			util.registerHandler('loginOutDeleteToken',res => {
				window.token = '';
				this.token = '';
				localStorage.removeItem('token');
			})
			util.callHandler('setStatusBarStyle',{
				style:'dark'
			})
		},500)
    }
}